<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>登录</title>
		<link rel="stylesheet" href="js/bower_components/bootstrap/dist/css/bootstrap.min.css">
		<link rel="stylesheet" href="js/bower_components/bootstrap-select/dist/css/bootstrap-select.min.css">
		<link rel="stylesheet" href="js/bower_components/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.min.css">
		<link rel="stylesheet" href="js/bower_components/bootstrap-table/dist/bootstrap-table.min.css">
		<link rel="stylesheet" href="js/bower_components/bootstrap-treeview/dist/bootstrap-treeview.min.css">
		<link href="js/bower_components/bootstrap-datetimepicker-master/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
		
		<script src="js/bower_components/jquery/dist/jquery.min.js"></script>
		<script src="js/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<script src="js/bower_components/bootbox.min.js"></script>
		<script src="js/bower_components/bootstrap-select/js/bootstrap-select.js"></script>
		<script src="js/bower_components/bootstrap-switch/dist/js/bootstrap-switch.min.js"></script>
		<script src="js/bower_components/bootstrap-table/dist/bootstrap-table.min.js"></script>
		<script src="js/bower_components/bootstrap-table/dist/locale/bootstrap-table-zh-CN.js"></script>
		
		<script src="js/bower_components/bootstrap-treeview/dist/bootstrap-treeview.min.js"></script>
		<script src="js/bower_components/jquery-form-validator/form-validator/jquery.form-validator.min.js"></script>
		<script src="js/bower_components/moment/min/moment-with-locales.min.js"></script>
		<script src="js/bower_components/bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.min.js"></script>
		<script>
			$(function(){
				//给登陆按钮注入点击事件
				$("#login").click(function(){
					//获取界面输入的值, 并且与后端接口进行对接。
					console.log("进入登录方法");
					MyUser={
						"username": $("#txtUsername").val(),
						"pwd": $("#txtPwd").val()
					}
					console.log("获取界面当中的值: ");
					console.log(MyUser);
					$.ajax({
						type:"put",
						url:"http://localhost:8081/myUser/getAll",
						contentType: "application/json;charset=utf-8",
						data: JSON.stringify(MyUser),
						dataType: "json",
						success:function(res){
							console.log(res);
							if (res.length == 1){
								alert("登录成功!");
							}else{
								alert("登录失败, 请重新输入!");
							}
						},
						error:function(myError){
							alert("登录失败, 请重新输入!");
						}
					});
				})
			})
		</script>
	</head>
	<body>
		<div class="panel-heading"><h2>登录</h2></div>
		<div class="panel-body">
			
			<div class="input-group">
				<span class="input-group-addon" id="basic-addon1">
					<span class="glyphicon glyphicon-user"></span>
				</span>
				<input type="text" id="txtUsername" name="txtUsername" class="form-control" placeholder="请输入登录账号"  />
			</div>
			<br />
			
			<div class="input-group">
				<span class="input-group-addon" id="basic-addon1">
					<span class="glyphicon glyphicon-lock"></span>
				</span>
				<input type="text" id="txtPwd" name="txtPwd" class="form-control" placeholder="请输入密码" />
			</div>
			<br />
			
			<div class="btn-group-lg text-right">
				<button id="login" type="button" class="btn btn-success">登录</button>
				<button id="zuce" type="button" class="btn btn-default">注册</button>
			</div>
		</div>
	</body>
</html>
